package twinb.interest;

import java.util.List;

import twinb.text.Kgram;
import twinb.text.Regex;
import twinb.text.TermVector;

public class ContentInterestModel extends InterestModelBase<String>
{
    public static final double w_rt = 0.4;
    public static final double w_search = 0.6;
    
    private Regex _regex = new Regex();
    private Kgram _kgram = new Kgram();
    
    protected void updateInterest(String text, double weight)
    {
        List<String> words = _regex.getWords(text);
        List<String> kgrams = _kgram.getKgrams(words);
        for (String kgram : kgrams)
        {
            addInterest(kgram, weight);
        }
    }
    
    public void retweet(String text)
    {
        updateInterest(text, w_rt);
    }
    
    public void search(String text)
    {
        updateInterest(text, w_search);
    }
    
    public TermVector getVector()
    {
    	TermVector vec=new TermVector(null);
    	vec.setVector(this.getVectorRepresentation());
    	return vec;
    }
}
